﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Pages_FileUpload : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void UploadButton_Click(object sender, EventArgs e)
    {
                if (FileUploadControl.HasFile)
                {
                    try
                    {
                        //Display information about the uploaded file
                        fname.Text = FileUploadControl.PostedFile.FileName.ToString();
                        ftype.Text = FileUploadControl.PostedFile.ContentType.ToString();
                        fsize.Text = FileUploadControl.PostedFile.ContentLength.ToString();

                        //create the path to save the file to
                        string fileName = Path.Combine(Server.MapPath("~/App_Data"), FileUploadControl.FileName);
                        //save the file to our local path
                        FileUploadControl.SaveAs(fileName);
                    }
                    catch (Exception ex)
                    {
                        fname.Text = "Error: The file could not be uploaded.  The following error occured: " + ex.Message;
                    }
            }
        }
    }
